package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/10/23 10:19
 **/
public class Day52_1_Num1768_MergeAlternately {
    class Solution {
        public String mergeAlternately(String word1, String word2) {
            StringBuffer sb = new StringBuffer();
            int i = 0;
            while(i < word1.length() || i < word2.length()){
                if(i < word1.length() && i < word2.length())
                    sb.append(word1.charAt(i)).append(word2.charAt(i));
                else if(i >= word1.length()) sb.append(word2.charAt(i));
                else if(i >= word2.length()) sb.append(word1.charAt(i));
                i++;
            }
            return sb.toString();
        }
    }
}